package com.ruoyi.business.service.impl;

import com.ruoyi.business.domain.Staff;
import com.ruoyi.business.mapper.StaffMapper;
import com.ruoyi.business.service.IStaffService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author win
 * @date 2021-06-14
 */
@Service
public class StaffServiceImpl implements IStaffService
{
    @Autowired
    private StaffMapper staffMapper;

    @Resource
    private IdWorker idWorker;

    /**
     * @return Staff
     */
    @Override
    public Staff selectStaffById(Long id)
    {
        return staffMapper.selectStaffById(id);
    }

    /**
     * @return Staff
     */
    @Override
    public List<Staff> selectStaffList(Staff depart)
    {
        return staffMapper.selectStaffList(depart);
    }

    /**
     * @return 结果
     */
    @Override
    public int insertStaff(Staff staff)
    {
        staff.setId(idWorker.nextId());
        staff.setCreateTime(DateUtils.getNowDate());
        staff.setCreateBy(SecurityUtils.getUsername());
        return staffMapper.insertStaff(staff);
    }

    /***
     * @return 结果
     */
    @Override
    public int updateStaff(Staff staff)
    {
        staff.setUpdateTime(DateUtils.getNowDate());
        staff.setUpdateBy(SecurityUtils.getUsername());
        return staffMapper.updateStaff(staff);
    }

    /**
     * @return 结果
     */
    @Override
    public int deleteStaffByIds(Long[] ids)
    {
        return staffMapper.deleteStaffByIds(ids);
    }

    /***
     * @return 结果
     */
    @Override
    public int deleteStaffById(Long id)
    {
        return staffMapper.deleteStaffById(id);
    }

    @Override
    public Staff selectStaffByIp(String clientIp) {
        return staffMapper.selectStaffByIp(clientIp);
    }

}
